package model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToMany;


@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(discriminatorType=DiscriminatorType.STRING,name="type")
public class Users implements Serializable{

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;
	
	@Column(name = "Nome")
	private String name;
	
	@Column(name="Telefone")
	private String phone;
	
	@Column(name="Username")
	private String username;
	
	@Column(name="Password")
	private String password;
	
	private String role;
	
	private String address;
	
	@OneToMany(cascade = CascadeType.ALL, mappedBy="user")
	private List<Process> processes = new ArrayList<Process>();
	

	public Users() {
		super();
	}
	
	public Users(String name, String telefone,String address, String username, String password, String role) {
		this.name = name;
		this.phone = telefone;
		this.address = address;
		this.username = username;
		this.password = password;
		this.role = role;
	}

	public Users(String name, String username, String password, String role){
		this.name=name;
		this.username=username;
		this.password=password;
		this.role = role;
	}
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String telefone) {
		this.phone = telefone;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	
	public List<Process> getProcesses(){
		return processes;
	}
	
	public void addProcesses(Process p){
		processes.add(p);
	}
	
	public void removeProcesses(Process p){
		processes.remove(p);
	}

	public String getRole() {
		return role;
	}

	public void setRole(String role) {
		this.role = role;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}
	
}
